package View;

import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionListener;
import java.io.Serializable;

import javax.swing.JTable;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
/** 
 * this class provide the GUI window for define and distribute categories
 */
public class SettingDistributionsView extends JFrame implements Serializable {
	static final long serialVersionUID = 42L; 
	/**
	 * required  fields and buttons 
	 */
	JLabel idLabel;
	JLabel lblCategory;
	JLabel lblType;
	JLabel lblProduct;
	JTextField txtCatID;
	JTextField txtCategory;
	JTextField txtName;
	JTable table;
	JTextField txtProduct;
	JButton btnBack;
	JButton btnSet;



	/**
	 * default and only constructor
	 */
	public SettingDistributionsView() {
		setTitle("Set Distributions");
		getContentPane().setLayout(null);
		this.setSize(400,400);


		this.setLocationRelativeTo(null); 		
		idLabel = new JLabel("Category ID");
		idLabel.setBounds(44, 20, 89, 17);
		getContentPane().add(idLabel);

		lblCategory = new JLabel("Category Name");
		lblCategory.setBounds(44, 60, 89, 17);
		getContentPane().add(lblCategory);

		lblType = new JLabel("Type Name");
		lblType.setBounds(44, 100, 89, 17);
		getContentPane().add(lblType);

		lblProduct = new JLabel("Product ID");
		lblProduct.setBounds(44, 140, 89, 17);
		getContentPane().add(lblProduct);


		txtCatID = new JTextField();
		txtCatID.setBounds(new Rectangle(156, 20, 127, 17));
		getContentPane().add(txtCatID);
		txtCatID.setColumns(10);

		txtCategory = new JTextField();
		txtCategory.setBounds(156, 60, 127, 17);
		getContentPane().add(txtCategory);
		txtCategory.setColumns(10);

		txtName = new JTextField();
		txtName.setBounds(156, 100, 127, 17);
		getContentPane().add(txtName);
		txtName.setColumns(10);

		txtProduct = new JTextField();
		txtProduct.setBounds(156, 140, 127, 17);
		getContentPane().add(txtProduct);
		txtProduct.setColumns(10);

		table = new JTable();
		table.setBounds(222, 239, 141, -41);
		getContentPane().add(table);

		btnBack = new JButton("Back");
		btnBack.setFont(new Font("Tahoma", Font.BOLD, 16));
		btnBack.setBounds(125, 285, 127, 46);
		getContentPane().add(btnBack);

		btnSet = new JButton("Set");
		btnSet.setFont(new Font("Tahoma", Font.BOLD, 16));
		btnSet.setBounds(125, 228, 127, 46);
		getContentPane().add(btnSet);

	}
	
	/**
	 * @param actionListener
	 */
	public void addSettingDistributionsListener(ActionListener actionListener){

		btnBack.addActionListener(actionListener);
		btnSet.addActionListener(actionListener);
	}

	/**
	 * show and hide window functions
	 */
	public void showWindow(){
		setVisible(true);
	}
	public void hideWindow(){
		setVisible(false);
	}	

	/**
	 * @return btnBack button
	 */
	public JButton btnBack() {
		return  this.btnBack;
	}
	/**
	 * @return btnSet button
	 */
	public JButton btnSet() {
		return  this.btnSet;
	}
	/**
	 * 
	 * @return text in txtCatID
	 */
	public String gettxtCatID(){
		return txtCatID.getText();
	}
	/**
	 * 
	 * @return text in txtCategory
	 */
	public String gettxtCategory(){
		return txtCategory.getText();
	}
	/**
	 * 
	 * @return text in txtName
	 */
	public String gettxtName(){
		return txtName.getText();
	}
	/**
	 * 
	 * @return the text in txtProduct
	 */
	public String getProduct(){
		return txtProduct.getText();
	}

	/**
	 * Function which clear fields
	 */
	
	public void clearFields(){
		txtCatID.setText(null);
		txtCategory.setText(null);
		txtName.setText(null);
		txtProduct.setText(null);

	}
}
